package com.fyzk.betzhushu.nxk3;

import java.math.BigInteger;
import java.util.List;

import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.betzhushu.ZhuShuBase;

public class Nxk3SanBuTongDan extends ZhuShuBase{

	private int num = 3;
	@Override
	public long betZhuShu(List<List<BallInfo>> balls) {
		int countDan = 0;
		int countTuo = 0;
		List<BallInfo> infosDan = balls.get(7);
		List<BallInfo> infosTuo = balls.get(8);
		
		for (int i = 0; i < infosDan.size(); i++) {
			if (infosDan.get(i).isSelected()) {
				countDan++;	
			}
		}
		
		for (int i = 0; i < infosTuo.size(); i++) {
			if (infosTuo.get(i).isSelected()) {
				countTuo++;	
			}
		}
		
		if (countDan == 0) {
			return 0;
		}
		num = 3 - countDan;
		return getZhuShu_common(countTuo);
	}
	
	/**
	 * 计算注数(任选n)
	 */
	private long getZhuShu_common(int hong){
		if (hong < num) {
			return 0;
		}else{
			BigInteger big = c_x_y(hong).divide(c_x_y(num)).divide(c_x_y(hong - num));
			return  big.longValue();
		}
	}
	
	private BigInteger c_x_y(int n){
		BigInteger big = new BigInteger(""+n);
		
		return (n == 0) ? new BigInteger("1") : big.multiply(c_x_y(n - 1)) ;
	}

}
